/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 *
 * Copyright 2010 yura, Version 2.0 (the "License");
 *
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 *
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *
 * Unless required by applicable law or agreed to in writing, software
 *
 * distributed under the License is distributed on an "AS IS" BASIS,
 *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 *
 * limitations under the License.
 */
package org.opu.doc2db.document.datadocument;

import org.simpleframework.xml.Element;

/**
 *  Specific class with metrics: the metrics and units of it
 * @author yura
 */
public class Metric<E> {
    
    /** The metric value */
    @Element
    private E metric;

    /** Units of  metric */
    @Element (required=false)
    private String name;

    public Metric() {
        this(null);
    }

    /**
     *  Create new instance without metric units
     * @param metric the metric value
     */
    public Metric( E metric) {
        this(metric, null);
    }

    /**
     *  Create new instance
     * @param metric the metric value
     * @param metricName units of  metric
     */
    public Metric(E metric,
            String name) {
        
        this.metric = metric;
        this.name = name;
    }

    /**
     *  Return the metric value
     * @return the metric value
     */
    public E getMetric() {
        return metric;
    }

    /**
     * Set new metric value
     * @param metric the metric value
     */
    public void setMetric(E metric) {
        this.metric = metric;
    }

    /**
     *  Return units of  metric
     * @return units of  metric
     */
    public String getName() {
        return name;
    }

    /**
     *  Set new units of  metric
     * @param name units of  metric
     */
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return '(' + String.valueOf(metric) 
                + (name != null? " " + metric: "") + ')';
    }

    public static Metric<Integer> emptyMetric() {
//        return new Metric<Integer>(0);
        return null;
    }
}
